<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" type="text/css" href="../css/common.css"/>
<link rel="stylesheet" type="text/css" href="../font/iconfont.css"/>
<style>
#dongtaibox{
	padding:0.2rem;
	background: #fff;
	box-shadow:0 0 1px #ccc;
	-webkit-box-shadow:1px 0 1px #ccc;
	position: relative;
}
#contetns{
	display: block;
	width:100%;
	border: 0;
	height: 20rem;
	overflow: hidden;
	font-size:16px;
}
#contetns:focus{
	outline: none;
}
#photos{
	flex-wrap:wrap;
	-webkit-flex-wrap: wrap;
}
.photoitem{
	width: 23.5%;
	height: 8rem;
	background: #eee;
	margin-bottom: 4px;
	overflow: hidden;
	margin-right: 4px;
}
#addimg{
	text-align: center;
	line-height: 8rem;
	font-size: 6rem;
	color: #ccc;
}
.biaoqin{
	width: 100%;
	height: auto;
	position: absolute;
	bottom: 0;
	left: 0;
	font-size: 2rem;
	color:orange;
	padding: 0.2rem 0 0.2rem 0;
}
.biaoqin-inner{
	padding: 0 0.5rem 0 0.5rem;
}
.yyshuru{
	display: block;
	text-align: center;
	height:3rem;
	line-height: 3rem;
	color: orangered;
	font-size: 14px;
	text-align: center;
}
</style>
</head>
<body>
<div id="jcontent" class="jcontent">
	<div id="dongtaibox">
		<textarea id="contetns" placeholder="您的评论也可以很精彩..."></textarea>
	</div>
	<a id="yyshuru" class="yyshuru"><i class="iconfont icon-yuyin"></i>&nbsp;&nbsp;试试语音输入</a>
</div>
<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

mui.plusReady(function(){
});

window.addEventListener("riconClick", function(e) {
	savePingLun();
});
	
mui('#jcontent').on('tap','#yyshuru', function() {
	startRecognize();
});

function savePingLun(){
	//隐藏输入法
	webapp.hideTypewriting(["contetns"]);
	var _content=document.getElementById("contetns").value;
	if(webapp.util.isNull(_content)){
		mui.toast("请填写您需要发表的内容");
		return false;
	}
	webapp.ajax({
		url:"/carLife/admin/interface/comment/add/save",
		data:{
			targetId:webapp.GetQueryString("id"),
			content:_content,
			type:1
		},
		success:function(json){
			if(json.code==200){
				if(webapp.GetQueryString("from")=="index"){
					mui.toast("评论成功");
					//触发list页面的
					var _webview=plus.webview.getWebviewById("list.html");
					mui.fire(_webview,"commentNumUpdate",{code:200,id:webapp.GetQueryString("id")});
					webapp.openByTpl({
						title:"动态详情",
						hrefs:"/tpl/detail.html?id="+webapp.GetQueryString("id")
					});
				}else{
					var _webview=plus.webview.getWebviewById("common-sub");
					mui.fire(_webview,"refreshList");
				}
			}else{
				mui.toast("请求失败");
			}
		}
	});	
}
function startRecognize() {
	var text=document.getElementById("contetns");
    if(plus.os.name=='Android'&&navigator.userAgent.indexOf('StreamApp')>0){
        plus.nativeUI.toast('当前环境暂不支持语音识别插件');
        return;
    }
    var options = {};
    options.engine = 'iFly';
    plus.speech.startRecognize( options, function ( s ) {
      text.innerHTML=text.value+s;
    }, function ( e ) {
    } );
}
</script>
</body>
</html>
